package com.springmvc.controller;

import com.springmvc.pojo.User;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class UserController {

    @RequestMapping("/")
    public String toregister() {

        return "register";
    }

//    @PostMapping("/register")
//    public String register(HttpServletRequest request, HttpServletResponse  response, HttpSession  session) {
//        String username = request.getParameter("username");
//        String password = request.getParameter("password");
//        System.out.println(username);
//        System.out.println(password);
//        System.out.println(request);
//        System.out.println(response);
//        System.out.println(session);
//        return "Ok";
//    }
//@PostMapping("/register")
//public String register(
//        @RequestParam(value = "userrname",required = false,defaultValue = "null") String name,
//        @RequestParam("password") String password,
//        @RequestParam("sex")Integer  sex) {
//    System.out.println("username: " + name);
//    System.out.println("password: " + password);
//    System.out.println("sex: " + sex);
//    return "Ok";
//}
//@PostMapping("/register")
//public String register(
//        String username,
//        String password,
//        Integer  sex) {
//    System.out.println("username: " + username);
//    System.out.println("password: " + password);
//    System.out.println("sex: " + sex);
//    return "Ok";
//}
//    @PostMapping("/register")
//    public String register(User  user) {
//        System.out.println("username: " + user.getUsername());
//        System.out.println("password: " + user.getPassword());
//        System.out.println("sex: " + user.getSex());
//        System.out.println("interest: " + user.getInterest());
//        System.out.println("intro: " + user.getIntro());
//        System.out.println(user);
//        return "Ok";
//    }
//    @PostMapping("/register")
//    public String register2(@RequestHeader("referer") String referer) {
//        System.out.println(referer);
//        return "Ok";
//
//    }
    @PostMapping("/register")
    public String register2(@RequestHeader("referer") String referer,
                            @CookieValue(value = "id",required = false,defaultValue = "2222") String id) {
        System.out.println(referer);
        System.out.println("cookie的id"+ id);
        return "Ok";

}



}
